/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "QLTTB_ORGAO_ESTACAO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrgaoEstacao.findAll", query = "SELECT o FROM OrgaoEstacao o ORDER BY o.oesId"),
    @NamedQuery(name = "OrgaoEstacao.findByOesId", query = "SELECT o FROM OrgaoEstacao o WHERE o.oesId = :oesId"),
    @NamedQuery(name = "OrgaoEstacao.findByOesOrgId", query = "SELECT o FROM OrgaoEstacao o WHERE o.oesOrgId = :oesOrgId"),
    @NamedQuery(name = "OrgaoEstacao.findByOesEstId", query = "SELECT o FROM OrgaoEstacao o WHERE o.oesEstId = :oesEstId")})
@SequenceGenerator(name = "sequenceOrgaoEstacao", sequenceName = "SQ_QLTTB_ORGAO_ESTACAO", allocationSize = 1)
public class OrgaoEstacao implements Serializable {

    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "OES_ID")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceOrgaoEstacao")
    private BigDecimal oesId;
    @JoinColumn(name = "OES_ORG_ID", referencedColumnName = "ORG_ID")
    @ManyToOne
    private Orgao oesOrgId;
    @JoinColumn(name = "OES_EST_ID", referencedColumnName = "EST_ID")
    @ManyToOne
    private Estacao oesEstId;

    public OrgaoEstacao() {
    }

    public OrgaoEstacao(BigDecimal oesId) {
        this.oesId = oesId;
    }

    public OrgaoEstacao(BigDecimal oesId, Orgao oesOrgId, Estacao oesEstId) {
        this.oesId = oesId;
        this.oesOrgId = oesOrgId;
        this.oesEstId = oesEstId;
    }

    public Estacao getOesEstId() {
        return oesEstId;
    }

    public void setOesEstId(Estacao oesEstId) {
        this.oesEstId = oesEstId;
    }

    public BigDecimal getOesId() {
        return oesId;
    }

    public void setOesId(BigDecimal oesId) {
        this.oesId = oesId;
    }

    public Orgao getOesOrgId() {
        return oesOrgId;
    }

    public void setOesOrgId(Orgao oesOrgId) {
        this.oesOrgId = oesOrgId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (oesId != null ? oesId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrgaoEstacao)) {
            return false;
        }
        OrgaoEstacao other = (OrgaoEstacao) object;
        if ((this.oesId == null && other.oesId != null) || (this.oesId != null && !this.oesId.equals(other.oesId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + this.oesId;
    }
}
